<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="app">
    <h3>{{ title }}</h3>
    <div>
      <button @click="count--">-</button>
      <span>{{ count }}</span>
      <button @click="count++">+</button>
    </div>
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        count: 100,
        title: '计数器'
      },
      //创建阶段（准备数据）
      beforeCreate() {
        console.log('beforeCreate, 响应是数据准备好之前,请求数据是不行的', this.count)
      },
      created() {
        // 可以进行发送请求
        console.log('created, 响应式数据已经创建完毕，请求数据可以', this.count)
      },

      // 挂载阶段(渲染页面)
      beforeMount() {
        console.log('beforeMount, 挂载之前', document.querySelector('h3').innerHTML)
      },
      mounted() {
        // 可以进行dom操作
        console.log('mounted, 挂载完毕', document.querySelector('h3').innerHTML)
      },

      // 更新阶段(修改数据→更新视图)
      beforeUpdate() {
        console.log('beforeUpdate')
      },
      updated() {
        console.log('updated')
      },

      // 销毁阶段(销毁实例)
      beforeDestroy() {
        console.log('beforeDestroy')
      },
      destroyed() {
        console.log('destroyed')
      }

    })
  </script>
</body>

</html>